package com.kl.chat;

import com.kl.decodeandencode.MyMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class NettyClientHandler extends SimpleChannelInboundHandler<MyMessage> {

    /**
     * 只要有消息就会触发读取
     */
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MyMessage msg) throws Exception {
        // msg是由前一个解码器解码后传递过来的，所以可以直接读取数据
        System.out.println("客户端感知===");
        System.out.println(new String(msg.getMessage()));
    }

}
